package com.iran.protoType.shallowCopy;

import java.util.Date;

public class Cat implements Cloneable {
    private int age;
    private String name;
    private String type;
    private CatBrand catBrand;
    private Date born;

    public Date getBorn() {
        return born;
    }

    public void setBorn(Date born) {
        this.born = born;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public CatBrand getCatBrand() {
        return catBrand;
    }

    public void setCatBrand(CatBrand catBrand) {
        this.catBrand = catBrand;
    }

    @Override
    public Cat clone() throws CloneNotSupportedException {
        //深赋值
        Cat deepClone = (Cat) super.clone();
        deepClone.setBorn((Date) this.born.clone());
        //浅复制
        Cat shallowCopy = (Cat) super.clone();
        return deepClone;
    }
}
